from PIL import Image
'''
image = Image.open('img.jpg')
a,b,c = image.format,image.size,image.mode
print(a,b,c)
image.show()
'''
#裁剪
'''
image = Image.open('img.jpg')
rect = 200,200,500,1300
image.crop(rect).show()
'''
#生成缩略图
'''
image = Image.open('img.jpg')
size = 256,256
image.thumbnail(size)
image.show()
'''
#缩放和黏贴图像
'''
img1 = Image.open('img.jpg')
img2 = Image.open('img2.png')
rect = 50,50,50,50
caijian = img2.crop(rect)
width,height = caijian.size
a = img1.paste(caijian.resize((int(width/1.5),int(height/1.5))),(172,40))
'''
#旋转和翻转
'''
image = Image.open('img.jpg')
image.rotate(180).show()  #旋转180°
image.transpose(Image.FLIP_LEFT_RIGHT).show()  #左右翻转
'''
#操作像素
'''
image = Image.open('img.jpg')
for x in range(200,300):
    for y in range(200,300):
        image.putpixel((x,y),(256,128,128))
image.show()
'''
#滤镜效果

from PIL import ImageFilter
image = Image.open('img.jpg')
image.filter(ImageFilter.CONTOUR).show()


